/**
 * <p>
 * Created on 2006-11-7 11:21:32 <br>
 * Copyright (c) 2006, All rights reserved.
 * </p>
 * @author Widen
 */
package com.widen.prima.editor.help;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;

public class OnlineHelpEditor
    extends EditorPart
{
    public static final String ID = "com.widen.prima.editor.onlinehelp";

    private OnlineHelpInput editorInput;

    public OnlineHelpEditor()
    {
        super();
    }

    public void doSave(IProgressMonitor monitor)
    {
    }

    public void doSaveAs()
    {
    }

    public void init(IEditorSite site, IEditorInput input)
        throws PartInitException
    {
        setSite(site);
        setInput(input);

        this.editorInput = (OnlineHelpInput) input;
        setPartName(editorInput.getName());
    }

    public boolean isDirty()
    {
        return false;
    }

    public boolean isSaveAsAllowed()
    {
        return false;
    }

    public void createPartControl(Composite parent)
    {
        parent.setLayout(new FillLayout());

        // Create a web browser
        Browser browser = new Browser(parent, SWT.NONE);

        // Navigate to Slashdot
        browser.setUrl(this.editorInput.getUrl());
    }

    public void setFocus()
    {
    }
}
